import request from "@/request/request";
import requestMock from "@/request/requestMock";

// 请求一级分类列表
export const reqCategory1List = () => {
    return request.get(`/admin/product/getCategory1`);
};

// 请求二级分类列表
export const reqCategory2List = (category1Id) => {
    return request.get(`/admin/product/getCategory2/${category1Id}`)
}

// // 请求三级分类列表
export const reqCategory3List = (category2Id) => {
    return request.get(`/admin/product/getCategory3/${category2Id}`)
}

// 请求mock的banner数据
export const reqBannerList = () => {
    return requestMock.get(`/mock-api/banner`)
}


// 请求mock的floor数据
export const reqFloorList = () => {
    return requestMock.get(`/mock-api/floor`)
}

// 请求搜索页的数据
export const reqSearchList = (searchParams) => {
    return request.post(`/api/list`, searchParams)
}

// 请求详细页数据
export const reqDetailList = (skuId) => {
    return request.get(`/api/item/${skuId}`)
}

// 添加购物车
export const reqAddOrUpdateCart = (skuId, skuName) => {
    return request.post(`/api/cart/addToCart/${skuId}/${skuName}`)
}

// 请求购物车列表
export const reqCartList = () => {
    return request.get(`/api/cart/cartList`)
}



//9. 切换单个商品的选中状态
export const reqCartSingleChange = (skuID, isChecked) => {
    return request.get(`/api/cart/checkCart/${skuID}/${isChecked}`);
};

//10. 切换全部商品的选中状态
export const reqCartAllChange = (isChecked, skuIdList) => {
    return request.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList);
};

//11. 删除单个商品
export const reqCartSingleDelete = (skuId) => {
    return request.delete(`/api/cart/deleteCart/${skuId}`);
};

//12. 删除所有选中的商品
export const reqCartAllDelete = (skuIdList) => {
    return request.post(`/api/cart/batchDeleteCart`, skuIdList);
};
//13. 注册获取验证码接口
export const reqUserCode = (phone) => {
    return request.get(`/api/user/passport/sendCode/${phone}`);
};

//14. 注册
export const reqRegister = (userInfo) => {
    return request.post(`/api/user/passport/register`, userInfo);
};

//15. 登录
export const reqLogin = (userInfo) => {
    console.log(userInfo, "userInfo");
    return request.post(`/api/user/passport/login`, userInfo);
};

//16.请求用户信息
export const reqUserMessage = () => {
    return request.get(`/api/user/passport/auth/getUserInfo`);
};


//17. 退出登录
export const reqLogout = () => {
    return request.get(`/api/user/passport/logout`);
};

//18. 获取交易页信息
export const reqTradeInfo = () => {
    return request.get(`/api/order/auth/trade`);
};

//19. 获取当前的收获地址
export const reqAddress = () => {
    return requestMock.get(`/mock-api/address`);
};

//20. 提交订单
export const reqAddOrder = (tradeNo, tradeDeatil) => {
    return request.post(
        `/api/order/auth/submitOrder?tradeNo=${tradeNo}`,
        tradeDeatil
    );
};

//21. 根据订单号获取支付详情
export const reqPayDetail = (orderId) => {
    return request.get(`/api/payment/weixin/createNative/${orderId}`)
}

//22. 查询当前的支付状态
export const reqPayStatus = (orderId) => {
    return request.get(`/api/payment/weixin/queryPayStatus/${orderId}`)
}